<?php 
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
    	$this->display();
    }

//执行登录
    public function dologin(){
        $username = I('post.username');
        $password = I('post.password');
    
        $data = M('user')->where(array('username'=>$username))->find();
        //dump($data);
    
        if (is_null($data)) {
            $this->error('用户名错误!');
            exit;
        }

        //密码判断
        if ($data['password'] !== $password) {
            $this->error('密码错误');
            exit;
        }

        //登录成功
        $_SESSION['fix_user'] = $data;

        //成功跳转
        $this->redirect('index/index', '', 1, 'Login ....');

    }

    public  function logout(){
        session(null);
        $this->success('欢迎再来',U('Admin/Login/index'),3);
    }    

}

